package com.hxq.controller.wechat;

import com.hxq.config.wechat.cp.WxCpConfiguration;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.message.WxCpAppChatMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("wxCp")
public class WxCpController {



    @GetMapping("test")
    public void test(@RequestParam Integer agentId) throws WxErrorException {
        WxCpService wxCpService = WxCpConfiguration.getCpService(agentId);
        WxCpMessage message = WxCpMessage.TEXT().agentId(agentId).content("测试").toUser("6410").build();
        WxCpMessageSendResult send = wxCpService.getMessageService().send(message);
        System.out.println(send);
    }
}
